package dao;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilders;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.els.ElsConnection;
import com.els.domain.QueryRespVO;
import com.els.factory.ElasticFactory;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.webapp.dao.AssessmentDataDAO;
import com.webapp.dao.CounselorDAO;
import com.webapp.dao.CounselorDetailDAO;
import com.webapp.dao.DictDAO;
import com.webapp.dao.DisputesDAO;
import com.webapp.dao.LoginCountDAO;
import com.webapp.dao.MediationDAO;
import com.webapp.dao.SessionDAO;
import com.webapp.dao.UserDAO;
import com.webapp.dao.UserDetailDAO;
import com.webapp.domain.entity.AssessmentData;
import com.webapp.domain.entity.Counselor;
import com.webapp.domain.entity.CounselorDetail;
import com.webapp.domain.entity.Dict;
import com.webapp.domain.entity.Disputes;
import com.webapp.domain.entity.LoginCount;
import com.webapp.domain.entity.Mediation;
import com.webapp.domain.entity.UserDetail;



@RunWith(SpringJUnit4ClassRunner.class)   
@ContextConfiguration(locations={"classpath:spring/spring-applicationContext.xml","classpath:spring/spring-servlet.xml"})

public class DAOtest {  
     
    @Autowired  
    SessionFactory sessionFactory; 
    @Autowired
    SessionDAO sessionDAO;
    @Autowired
    MediationDAO mediationDAO;
    @Autowired
    DisputesDAO disputesDAO;
    @Autowired
    UserDetailDAO userDetailDAO;
    @Autowired
    UserDAO userDAO;
    @Autowired
    DictDAO ditDAO;
    @Autowired
    CounselorDAO counselorDAO;
    @Autowired
    CounselorDetailDAO counselorDetailDAO;
    @Autowired
    AssessmentDataDAO assessmentDataDAO;
    @Autowired
    LoginCountDAO loginCountDAO;
    
    
    public Session getSession(){
    	return sessionFactory.openSession();
    }
    
    @Test
    public void sessionFactoryTest(){
    	org.hibernate.Session sess = sessionFactory.getCurrentSession();
    	Object object = sess.get(Session.class, 1l);
    	System.err.println(object.toString());
    	com.webapp.domain.entity.Session session = sessionDAO.get(1l);
    	JsonObject jsonObject = session.toJsonObject();
    	System.err.println(jsonObject);
    }
    @Test
    public void sessionFactoryTest2(){
    	com.webapp.domain.entity.Session session = sessionDAO.get(172L);
    	System.err.println(session.getId());
    }
    
    
    @Test
    public void saveTest(){
    	Disputes disputes = new Disputes();
    	disputes.setName("xxx");
    	Mediation mediation = new Mediation();
    	mediation.setDisputes(disputes);
    	mediation.setCode("code");
    	Serializable id = getSession().save(mediation);
    	System.err.println(id);
    	
    }
    
    @Test
    public void saveTest2(){
    	Disputes disputes = new Disputes();
    	Mediation mediation = new Mediation();
    	mediation.setCode("test");
    	disputes.setMediation(mediation);
    	
    	Serializable id = getSession().save(disputes);
    	System.err.println(id);
    	
    }
    @Test
    public void upTest(){
    	Disputes disputes = disputesDAO.load(2l);
//    	Mediation mediation = disputes.getMediation();
    	Mediation mediation = mediationDAO.load(6l);
//    	mediation.setCode("merge");
    	disputes.setMediation(mediation);
    	disputesDAO.merge(disputes);
//    	getSession().merge(disputes);
//    	getSession().update(disputes);
//    	System.err.println(id);
    	
    }
    @Test
    public void upTest2(){
    	Disputes disputes = new Disputes();
    	getSession().save(disputes);
    	
    }
    /////////////////////////////////////
    @Test
    public void save22222(){
    	Disputes disputes = new Disputes();
    	disputes.setName("22");
    	Mediation mediation = new Mediation();
    	mediation.setDisputes(disputes);
    	getSession().save(mediation);
    }
    @Test
    public void save22233(){
    	Session session = sessionFactory.openSession();
    	Disputes disputes = (Disputes) session.get(Disputes.class, 3l);
    	
    	Mediation mediation = (Mediation) session.get(Mediation.class, 7l);
    	disputes.setMediation(mediation);
    	getSession().merge(disputes);
    }
    
    
    @Test
    public void  fetchTest(){
    	com.webapp.domain.entity.Session session = sessionDAO.fetch(2l);
    	System.err.println(session);
    	
    }
    @Test
    public void testgetCountSessionByDisputesId(){
    	int count = sessionDAO.getCountSessionByDisputesId(44l);
    	System.err.println(count);
    }
    
    @Test
    public void testupdateUserDetail(){
    	UserDetail userDetail = userDetailDAO.get(11l);
    	userDetail.setArea("xx");
//    	userDetailDAO.updateUserDetail(userDetail);
    	userDetailDAO.update(userDetail);
    }
    @Test
    public void testUsere(){
    	int list=userDAO.testUser("asss");
    	System.err.println(list);
    	
    	
    }
 
    @Test
    public void insert(){
    	int n = 97;
		
		List<JsonObject> list = getelsData();
		List<Counselor> dd = counselorDAO.loadAll();
		for (JsonObject jsonObject : list) {
			
		}
		
		
		Counselor counselor = null;
//		CounselorDetail counselorDetail = null;
		String[] strs = new String[]{
				"1","2","3","4","5","6","29",
				"10","11","12","13","14","15","100","101",
				"16","17","18","19","20","21","22","23",
				"24","25","26","30","31","32","33","34",
				"35","36","37","39","40","41",
				"42","43","44","45","46","47","48","49"
		};
		List<String> arrlist = Arrays.asList(strs);
		for (JsonObject jsonObject : list) {
			String name = jsonObject.get("name").getAsString();
			long id = jsonObject.get("id").getAsLong();
			String userName = PinyinUtil.getPinYin(name);
			userName = userName.replaceAll(" ", "");
			String sex = jsonObject.get("sex").getAsString();
			String birth = jsonObject.get("birth").getAsString();
			String area = jsonObject.get("area").getAsString();
			String phone = jsonObject.get("phone").getAsString();
			String ability;
			try {
				ability = jsonObject.get("ability").getAsString();
			} catch (Exception e1) {
				ability = null;
//				e1.printStackTrace();
			}
//			counselor = counselorDAO.get(id);
			counselor = new Counselor();
			counselor.setName(userName);
			counselor.setCreateDate(new Date());
			counselor.setPassword("xihu");
			counselor.setIsLogin("0");
			counselor.setHeadPortrait(String.valueOf(id));
			boolean is = arrlist.contains(String.valueOf(id));
			if (!is && id>n) {
				
				counselorDAO.save(counselor);
//				getSession().save(counselor);
			}else{
				continue;
//				counselor.setId(id);
//				getSession().update(counselor);
//				counselorDAO.update(counselor);
				
			}
			
			//
//			counselorDetail.setName(userName);
//			counselorDetail.setActualName(name);
//			counselorDetail.setSex(sex);
//			counselorDetail.setBirth(birth);
//			counselorDetail.setArea(area);
//			counselorDetail.setPhone(phone);
//			counselorDetail.setAbility(ability);
//			counselor.setCounselorDetail(counselorDetail);
//			counselorDetail.setId(id);
//			counselorDetail.setCounselor(counselor);
			
		
		
			
		}
	}
	
    @Test
    public void xxxxxxxxxx(){
    	Session session = getSession();
    	Counselor counselor = (Counselor) session.get(Counselor.class, 10l);
    	CounselorDetail counselorDetail = new CounselorDetail();
    	counselorDetail.setName(counselor.getName());
    	counselorDetail.setCounselor(counselor);
    	Serializable id = session.save(counselorDetail);
    	System.err.println(id);
    }
    
    @Test
    public void xxxxxxxcxxx(){
    	List<Counselor> ss = counselorDAO.loadAll();
    	for (int i = 0; i < ss.size(); i++) {
//    		counselorDAO.inserCounselor(counselor)
			
		}
    	
    }
    
    
    
    
    @Test
    public void bb (){
    	
    	String[] strs = new String[]{
				"1","2","3","4","5","6","29"};
    	List<String> arrlist = Arrays.asList(strs);
    	Session session = getSession();
		List<JsonObject> list = getelsData();
		for (JsonObject jsonObject : list) {
			long id = jsonObject.get("id").getAsLong();
			if (!arrlist.contains(String.valueOf(id))) {
				continue;
			}
			Counselor counselor = (Counselor) session.get(Counselor.class, id);
	    	CounselorDetail counselorDetail = new CounselorDetail();
	    	counselorDetail.setCounselor(counselor);
	    	
			String name = jsonObject.get("name").getAsString();
			String userName = PinyinUtil.getPinYin(name);
			userName = userName.replaceAll(" ", "");
			String sex = jsonObject.get("sex").getAsString();
			String birth = jsonObject.get("birth").getAsString();
			String area = jsonObject.get("area").getAsString();
			String phone = jsonObject.get("phone").getAsString();
			String ability;
			try {
				ability = jsonObject.get("ability").getAsString();
			} catch (Exception e1) {
				ability = null;
//				e1.printStackTrace();
			}
			counselorDetail.setName(userName);
			counselorDetail.setActualName(name);
			counselorDetail.setSex(sex);
			counselorDetail.setBirth(birth);
			counselorDetail.setArea(area);
			counselorDetail.setPhone(phone);
			counselorDetail.setAbility(ability);
			
//			session.update(counselorDetail);
		}
		
		
    	System.err.println("wan");
		
    }
    
//    {"name":"兰艳霞","sex":"女","birth":"1983年6月","education":"硕士","role":"律师","job":"浙江五联律师事务所律师专职律师","jobstart":"2008.0","ability":["民商事","劳动争议"],"status":"0","area":"浙江省","address":"浙江省杭州市上城区龙舌路46号大名空间6楼","phone":"13819129897","resume":"兰艳霞律师，中央民族大学经济法硕士，浙江五联律师事务所合伙人，任浙江省法学会金融法学研究会理事，杭州市总工会法律工作者，杭州市律师协会2011年度律师“新星奖”；专长于公司、证券及银行等法律领域；先后为花旗银行（citi bank）、国家开发银行浙江省分行（CDB）、比利时联合银行（KBC）、浙江省工业研究所、浙江省技术创新服务中心、浙江广播电视报社、贝因美集团公司等多家银行、事业单位及上市公司提供法律服务；作为项目律师，为企业股票发行并上市项目（IPO）、企业并购项目（A&M）、企业股权并购项目银行融资、石油开发项目银行融资、企业债务危机资产重组等多个大中型项目提供法律服务","photo":"zixunshi_7","id":7,"_id":"AViK-dPm1MBZ4LPdmGPm","_type":"xxx"}
//    {"name":"邵慧萍","sex":"女","birth":"1969年2月","education":"硕士","role":"律师","job":"北京浩天信和（杭州）律师事务所","jobstart":"2000.0","ability":["民商事"],"status":"0","area":"浙江省","address":"浙江省杭州市省府路29号三楼 ","phone":"13858053800","resume":"1991-1999年期间在浙江信联股份有限公司从事人力资源管理工作。2000年开始从事专职律师工作，主要专业领域：公司法及投融资服务、知识产权法律服务、企业劳动争议法律服务及民商事的重大诉讼活动。担任了浙江省工商联、浙江省文物局、浙江申达机器制造股份有限公司等十余家机关、企事业单位的常年法律顾问，为浙商及其在外投资经营活动提供优质高效的法律服务；办理过许多重大的民商事及金融案件，为上海浦发银行、中国工商银行等多家金融单位和许多企事业单位挽回了重大经济损失。办理过大量有影响力的知识产权案件，依法维护了“PUMA”、“西湖龙井”、“龙井茶”、“安吉白茶”、“方太”、“康恩贝”等商标权和品牌价值。近几年来，开拓并参与了企业资产并购和重组、证券及基金业务等非诉法律事务。","photo":"zixunshi_8","id":8,"_id":"AViK-dPm1MBZ4LPdmGPs","_type":"xxx"}
//    {"name":"孙旭权","sex":"男","birth":"1984年3月","education":"在职硕士研究生在读","role":"律师","job":"浙江易盟律师事务所合伙人","jobstart":"2010.10月","ability":["家事"],"status":"0","area":"浙江省","address":"古墩路616号同人精华","phone":"13666633488","resume":"律师行合伙人兼任党支部书记，业务专长：婚姻家事与继承法务，私人财富规划与法律风险防范及争议解决","photo":"zixunshi_9","id":9,"_id":"AViK-dPm1MBZ4LPdmGP3","_type":"xxx"}

    
    
    
    
    
   public List<JsonObject> getelsData(){
    	String indexName = "xxx";
		QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
		ElsConnection ec = ElasticFactory.getConnection();
//		List<JsonObject> list = ec.queryAllByQueryBuilder(indexName, indexName, queryBuilder);
		SearchRequestBuilder request=ec.prepareSearch(indexName, indexName, queryBuilder);
		request.addSort(SortBuilders.fieldSort("id"));
		request.setSize(100).setFrom(0);
		QueryRespVO result = ec.executeQueryRequest(request);
		List<JsonObject> list = result.getData();
		return list;
    }
   @Test
    public void queryCounselor(){
    	List<Counselor> list = counselorDAO.loadAll();
    	System.err.println(list.size());
    	ElsConnection ec = ElasticFactory.getConnection();
    	List<JsonObject> jsonList = new ArrayList<JsonObject>();
    	JsonObject jsonObject = null;
    	for (int i = 0; i < list.size(); i++) {
			Counselor counselor = list.get(i);
			CounselorDetail counselorDetail = counselor.getCounselorDetail();
			jsonObject = new JsonObject();
//			"name","sex","birth","education","role","job","jobstart","ability","status","area",
//			"address","phone","resume","photo","id"
			if (counselor.getId()==6) {
				continue;
			}
			try {
				jsonObject.addProperty("name", counselorDetail.getActualName());
			} catch (Exception e) {
				System.err.println("xx");
				e.printStackTrace();
			}
			jsonObject.addProperty("sex",counselorDetail.getSex());
			jsonObject.addProperty("birth",counselorDetail.getBirth());
//			jsonObject.addProperty("education",counselorDetail.get);
//			jsonObject.addProperty("role",counselorDetail.get);
//			jsonObject.addProperty("job",counselorDetail.get);
//			jsonObject.addProperty("jobstart",counselorDetail.get);
			jsonObject.addProperty("ability",counselorDetail.getAbility());
			jsonObject.addProperty("area",counselorDetail.getArea());
			jsonObject.addProperty("address",counselorDetail.getAddress());
			jsonObject.addProperty("phone",counselorDetail.getPhone());
//			jsonObject.addProperty("resume",counselorDetail.getr);
			jsonObject.addProperty("photo","zixunshi_"+counselor.getId());
			jsonObject.addProperty("id",counselor.getId());
			jsonList.add(jsonObject);
			
		}
    	ec.singleBulkIndex("xxx", "xxx", jsonList, null);
    	
    }
   
   @Test
    public void insertapp (){
    	AssessmentData assessmentData = new AssessmentData();
    	assessmentData.setAttorneyFee("1");
    	long id = (Long) assessmentDataDAO.save(assessmentData);
    	System.err.println(id);
    	
    }
   @Test
	public void insert22() throws Exception{
	   List<Dict> dicts = ditDAO.findListByType("dis_type");
	   	List<String> dictStrings = new ArrayList<String>();
	   	for (Dict dict : dicts) {
	   		dictStrings.add(dict.getDescribes().trim());
	   		System.err.println(dict.getDescribes().trim());
		}
	   //
	   File file=new File("C:\\Users\\Administrator\\Desktop\\ODR服务资源数据\\当事人诉讼成本数据-20170211.xlsx");
		FileInputStream is=new FileInputStream(file);
		XSSFWorkbook xxx = new XSSFWorkbook(is); 
		XSSFSheet sheet = xxx.getSheetAt(0);
		int trlength=sheet.getLastRowNum();//总行数
//		int trlength=69;
//		HSSFRow row=sheet.getRow(0);
		XSSFRow row=sheet.getRow(1);
		int tdlength=row.getLastCellNum();//总列数
		
		for (int i = 2; i < trlength+1; i++) {	
			//XSSFCell cell=sheet.getRow(i).getCell(13);
			XSSFRow row2=sheet.getRow(i);
			XSSFCell cell = sheet.getRow(i).getCell(1);
			String type = null;
			try {
				type = cell.toString().trim();
			} catch (Exception e) {
				// TODO Auto-generated catch block
//				e.printStackTrace();
				break;
			}
//			dictStrings.contains(type) ||
//			物业纠纷               物业服务合同纠纷
//			损害赔偿纠纷       财产损害赔偿纠纷
//			房屋买卖纠纷      房屋买卖合同纠纷
//			建设工程纠纷		建设工程合同纠纷
//			公司权益纠纷      侵害企业出资人权益纠纷
//			医疗纠纷		医疗损害责任纠纷
//			知识产权纠纷       知识产权合同纠纷
			if (
					"知识产权合同纠纷".equals(type)
					) {
				type = "知识产权纠纷";
				System.out.println(type);
				AssessmentData assessmentData = new AssessmentData();
				assessmentData.setCode(dicts.get(dictStrings.indexOf(type)).getCode());
		    	assessmentData.setType(type);
		    	assessmentData.setJieAnShu(row2.getCell(2).toString());
		    	assessmentData.setTotalDaysTrial(row2.getCell(3).toString());
		    	assessmentData.setAverageTrialDays(row2.getCell(4).toString());
		    	assessmentData.setUnderlyingAmount(row2.getCell(5).toString());
		    	assessmentData.setTheFeeFor(row2.getCell(21).toString());
		    	assessmentData.setAttorneyFee(row2.getCell(22).toString());
		    	assessmentData.setLostWages(row2.getCell(23).toString());
		    	assessmentData.setEconomicCost(row2.getCell(24).toString());
		    	assessmentData.setTimeCost(row2.getCell(25).toString());
		    	assessmentData.setWinningProbability(row2.getCell(27).toString());
		    	assessmentData.setSumOfRecover(row2.getCell(28).toString());
		    	assessmentData.setOnlineMediationCosts(row2.getCell(32).toString());
		    	assessmentData.setOnlineMediationProceeds(row2.getCell(33).toString());
		    	
		    	
		    	
		    	
		    	long id = (Long) assessmentDataDAO.save(assessmentData);
				
				
				
			}

//			机动车交通事故责任纠纷
//		   JsonObject jsonObject=new JsonObject();
//			for (int j = 1; j < tdlength; j++) {
//				XSSFCell cell=sheet.getRow(i).getCell(j);
//			}
			
//			离婚纠纷
//			劳动争议
//			机动车交通事故责任纠纷
//			合同纠纷
//			民间借贷纠纷
//			继承纠纷
//			证券纠纷
//			物业纠纷               物业服务合同纠纷
//			损害赔偿纠纷       财产损害赔偿纠纷
//			房屋买卖纠纷      房屋买卖合同纠纷
//			建设工程纠纷		建设工程合同纠纷
//			公司权益纠纷      侵害企业出资人权益纠纷
//			医疗纠纷		医疗损害责任纠纷
//			知识产权纠纷       知识产权合同纠纷

//			刑事案件 
//			电子商务
//			其他纠纷
			
			
			
		}
	}
 
    @Test
    public void selectdis(){
    	List<Dict> dicts = ditDAO.findListByType("dis_type");
    	List<String> dictStrings = new ArrayList<String>();
    	for (Dict dict : dicts) {
    		dictStrings.add(dict.getDescribes());
		}
    }
    
    @Test
    public void sum(){
//    	1795479.12                                                                     准备诉讼材料时间7  拟写起诉状时间8    诉讼费缴纳时间10  诉中调解时间11   证据交换时间12     补充材料时间13                         到庭宣判时间15  诉讼费结算时间17 申请立案执行时间18 提供线索参与执行时间19
    	String[] strings = new String[]{"249372.1","299246.52","49874.42","199497.68","174560.47","124686.05","149623.26","99748.84","274309.31","174560.47"};
    	double d = 0;
    	for (String string : strings) {
			double e = Double.valueOf(string);
			d+=e;
		}
    	System.err.println(d);
    	System.err.println(d/52694);
    }
    
    @Test
   	public void insert222() throws Exception{
//    	Session session = getSession();
//    	AssessmentData assessmentData = (AssessmentData) session.get(AssessmentData.class, 4l);
//    	AssessmentData assessmentData = assessmentDataDAO.get(1l);
   	   File file=new File("C:\\Users\\Administrator\\Desktop\\ODR服务资源数据\\当事人诉讼成本数据-20170211.xlsx");
   		FileInputStream is=new FileInputStream(file);
   		XSSFWorkbook xxx = new XSSFWorkbook(is); 
   		XSSFSheet sheet = xxx.getSheetAt(0);
   		int trlength=sheet.getLastRowNum();//总行数
//   		int trlength=69;
//   		HSSFRow row=sheet.getRow(0);
   		XSSFRow row=sheet.getRow(1);
   		int tdlength=row.getLastCellNum();//总列数
   		
   		for (int i = 2; i < trlength+1; i++) {	
   			//XSSFCell cell=sheet.getRow(i).getCell(13);
   			XSSFRow row2=sheet.getRow(i);
   			XSSFCell cell = sheet.getRow(i).getCell(1);
   			String type = null;
   			try {
   				type = cell.toString().trim();
   			} catch (Exception e) {
   				// TODO Auto-generated catch block
//   				e.printStackTrace();
   				break;
   			}
//   			dictStrings.contains(type) ||
//   			物业纠纷               物业服务合同纠纷
//   			损害赔偿纠纷       财产损害赔偿纠纷
//   			房屋买卖纠纷      房屋买卖合同纠纷
//   			建设工程纠纷		建设工程合同纠纷
//   			公司权益纠纷      侵害企业出资人权益纠纷
//   			医疗纠纷		医疗损害责任纠纷
//   			知识产权纠纷       知识产权合同纠纷
   			if (
   					"民间借贷纠纷".equals(type)
   					) {
//   				type = "知识产权纠纷";
   				System.out.println(type);
   				List<String> strings = new ArrayList<String>();
   		    	strings.add(row2.getCell(7).toString());
   		    	strings.add(row2.getCell(8).toString());
   		    	
   		    	strings.add(row2.getCell(10).toString());
   		    	strings.add(row2.getCell(11).toString());
   		    	strings.add(row2.getCell(12).toString());
   		    	strings.add(row2.getCell(13).toString());
   		    	
   		    	strings.add(row2.getCell(15).toString());
   		    	strings.add(row2.getCell(17).toString());
   		    	strings.add(row2.getCell(18).toString());
   		    	strings.add(row2.getCell(19).toString());
   		    	AssessmentData assessmentData = new AssessmentData();
   		    	assessmentData.setTotalDays(getsum(strings));
   		    	assessmentData.setPerformDays(row2.getCell(20).toString());
   		    	System.err.println(assessmentData.getTotalDays());
   		    	System.err.println(assessmentData.getPerformDays());
//   		    	session.update(assessmentData);
//   		    	 assessmentDataDAO.update(assessmentData);
   				assessmentDataDAO.save(assessmentData);
   				return ;
   				
   			}


   		}
   	}
    
    public String getsum(List<String> list){
    	double d = 0;
    	for (String string : list) {
			double e = Double.valueOf(string);
			d+=e;
		}
    	return d+"";
    }
    
    
    
    @Test
    public  void loginCountDAO_test() throws ParseException{
    	Object o = loginCountDAO.getMaxDateLoginCount_user(52);
    	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	Date d = dateFormat.parse(o.toString());
    	System.err.println(d);
    }
    
    

} 